#import "AIGOMapAnnotationView.h"
#import "Define.h"

@implementation AIGOMapAnnotationView
- (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier andDelegate:(id)delegate
{
    self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
    if (self != nil)
    {
        _delegate = delegate;
        CGRect frame = self.frame;
        frame.size = CGSizeMake(10, 20);
        self.frame = frame;
        self.backgroundColor = [UIColor clearColor];
        self.centerOffset = CGPointMake(-5, -10.0);
        [self initInterfaceWithAnotation:annotation];
    }
    return self;
}

- (void)initInterfaceWithAnotation:(id <MKAnnotation>)annotation
{
    UIImage *car1Image = IMG_PIN_DUMMY;
    
    _avatarImageView = [[UIImageView alloc] initWithFrame:CGRectMake(-car1Image.size.width/2, 0, car1Image.size.width, car1Image.size.height)];
    _avatarImageView.image = car1Image;
    [self addSubview:_avatarImageView];
}

- (void)loadInterfaceWithAnotation:(id<MKAnnotation>)annotation andImage:(UIImage *)image
{
    _avatarImageView.image = image;
    _avatarImageView.frame = CGRectMake(-image.size.width/2, 0, image.size.width, image.size.height);
}

@end
